package com.hongye.broker.controller;

import com.hongye.broker.service.HouseService;
import com.hongye.broker.vo.HouseSelectVo;
import com.hongye.common.entity.HouseEntity;
import com.hongye.common.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/house")
public class HouseController {
    @Autowired
    private HouseService houseService;

    @RequestMapping("/list")
    public List<HouseEntity> list(){
        return houseService.list();
    }
    //买房成交
    @RequestMapping("/mai")
    public ResponseResult maifang() {
        List<HouseEntity> list = houseService.maifang();
        Map<String, Object> map = new HashMap<>();
        map.put("list", list);
        return new ResponseResult(200, "卖房成交", map);
    }

    /*
    * 新房接口
    * */
    @RequestMapping("/newHouse")
    public ResponseResult newHouse(@RequestBody HouseSelectVo houseSelectVo){
        ResponseResult responseResult = houseService.list(houseSelectVo);
        return responseResult;
    }

    /*
    * 二手方接口
    * */
    @RequestMapping("/twoHouse")
    public ResponseResult twoHouse(@RequestBody HouseSelectVo houseSelectVo){
        ResponseResult responseResult = houseService.twoList(houseSelectVo);
        return responseResult;
    }
}
